package com.fh.shop.admin.controller.cate;

import com.fh.shop.admin.biz.cate.ICateService;
import com.fh.shop.admin.common.ServerResponse;
import com.fh.shop.admin.po.cate.Cate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/cate")
public class CateController {
    @Resource(name = "cateService")
    private ICateService cateService;

    @GetMapping("/toIndex")
    public String toIndex(){
        return "cate/index";
    }

    @GetMapping("/list")
    @ResponseBody
    public ServerResponse list(){
        return cateService.findCateList();
    }

    @PostMapping("/add")
    @ResponseBody
    public ServerResponse add(Cate cate){
        return cateService.addCate(cate);
    }

    @PostMapping("deleteCate")
    @ResponseBody
    public ServerResponse deleteCate(String ids){
        return cateService.deleteCate(ids);
    }

    @PostMapping("findCate")
    @ResponseBody
    public ServerResponse findCate(Long id){
        return cateService.findCate(id);
    }

    @PostMapping("updateCate")
    @ResponseBody
    public ServerResponse updateCate(Cate cate){
        return cateService.updateCate(cate);
    }

    @PostMapping("findCateByFatherId")
    @ResponseBody
    public ServerResponse findCateByFatherId(Long id){
        return cateService.findCateByFatherId(id);
    }
}
